package patrol.mobile.com.mobilepatrol.api;

import com.zhy.http.okhttp.OkHttpUtils;
import com.zhy.http.okhttp.request.RequestCall;

import java.util.Map;

import patrol.mobile.com.mobilepatrol.manager.UserManager;
import patrol.mobile.com.mobilepatrol.utils.Constants;
import patrol.mobile.com.mobilepatrol.utils.SPUtils;

/**
 * Created by apple on 17/9/27.
 */

public class HttpUtils {
    public static RequestCall get(String url, Map<String, String> map) {
        return OkHttpUtils
                .get()
                .addParams("userName", UserManager.getUser((String) SPUtils.get(Constants.current_id, "")).username)
                .addParams("passWord", UserManager.getUser((String) SPUtils.get(Constants.current_id, "")).pw)
                .params(map)
                .url(SPUtils.get(Constants.current_ser,"") + url)
                .build();
    }

    public static RequestCall post(String url, Map<String, String> map) {
        return OkHttpUtils
                .post()
                .addParams("userName", UserManager.getUser((String) SPUtils.get(Constants.current_id, "")).username)
                .addParams("passWord", UserManager.getUser((String) SPUtils.get(Constants.current_id, "")).pw)
                .params(map)
                .url(SPUtils.get(Constants.current_ser,"") + url)
                .build();
    }



}
